package com.spider.iceCream.mapper;

import com.spider.iceCream.entity.DayRank;
import com.spider.iceCream.entity.Video;
import com.spider.iceCream.spiderComponent.model.Rank;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Lord
 * @date 2021/7/14 15:15
 */
@Mapper
@Repository
public interface DayRankMapper {
    /**
     * 返回是否存在视频信息
     * @param dayRank 当日排名
     * @return true or false
     */
    @Select("select * from rankHistory where oid = #{oid} and rankDate = #{rankDate} and category = #{category}")
    public DayRank isExistRank (DayRank dayRank);

    /**
     * 返回视频信息
     * @param dayRank 当日排名
     * @return true or false
     */
    @Select("select * from rankHistory where rankDate = #{rankDate} and category = #{category}")
    public List<DayRank> getRank (DayRank dayRank);

    /**
     * 返回视频信息
     * @param oid id
     * @return true or false
     */
    @Select("select * from rankHistory where oid = #{oid}")
    public List<DayRank> getRankHistory (Integer oid);

    /**
     * 返回单个视频信息
     * @param oid 当日排名
     * @param date 日期
     * @return true or false
     */
    @Select("select * from rankHistory where oid = #{oid} and rankDate = #{date}")
    public List<DayRank> getSingleRank (Integer oid,String date);

    /**
     * 添加视频
     * @param dayRank 视频排行信息
     * @return true or false
     */
    @Insert("insert into rankHistory (oid,rank,category,rankDate,score) values (#{oid},#{rank},#{category},#{rankDate},#{score})")
    public int insertVideo(DayRank dayRank);

    /**
     * 返回单个视频信息
     * @return true or false
     */
    @Select("select * from rankHistory where 1")
    public List<DayRank> test ();
}
